from lib.webui_permission import *

class c73259a:
    # name = '查看自己创建产品的申请记录，先申请5个-c73259a'  # 测试用例名字

    cases = [
        ('c73259a1','wanglubo','123456'
         ),
        ('c73259a2','zhang1','123456'
         ),
        ('c73259a3','zhang2','123456'
          ),
        ('c73259a4','zhang3', '123456'
          ),
        ('c73259a5', 'zhangchengcheng', '123456'
           )
    ]

    # 测试用例步骤
    def teststeps(self, para_index):
        # 取出参数
        username, password = self.cases[para_index][1:3]
        # 下面写登录流程
        driver = webdriver.Firefox()
        driver.implicitly_wait(10)

        driver.get('http://172.17.66.19:8080/')

        driver.find_element(By.NAME, "username").send_keys(username)
        driver.find_element(By.NAME, "password").send_keys(password)
        driver.find_element(By.CSS_SELECTOR, ".el-button").click()
        if para_index > 3:
            time.sleep(1)
            right_btn = driver.find_element(By.CSS_SELECTOR,
                                    ".el-icon-arrow-right"
                                    )
            time.sleep(1)
            right_btn.click()

        STEP(2, "用5个不同的任意账户分别申请试用5个产品")
        # apply_css = self.cases[para_index][3]
        time.sleep(1)
        # apply_btn = driver.find_element(By.CSS_SELECTOR,apply_css)
        # apply_btn.click()
        apply_btn_list = driver.find_elements(By.CLASS_NAME,
                                              'product-card-button-second'
                                              )
        apply_btn_list[para_index % 4].click()
        time.sleep(1)

        STEP(3, "申请试用")
        commit_apply_productor(driver)
        time.sleep(1)
        # wait = WebDriverWait(driver, 10, 0.5)
        # wait.until(EC.presence_of_element_located((By.CLASS_NAME, "el-form-item__label")))
        driver.quit()